package cn.sytton.taffe.file.config;

/**
 * Minio存储桶权限配置
 *
 * @author skyrock
 */
public class MinioPolicy {
    private static final String PUBLIC_POLICY = "{\n" +
            "  \"Version\": \"2012-10-17\",\n" +
            "  \"Statement\": [\n" +
            "    {\n" +
            "      \"Effect\": \"Allow\",\n" +
            "      \"Principal\": {\n" +
            "        \"AWS\": [\n" +
            "          \"*\"\n" +
            "        ]\n" +
            "      },\n" +
            "      \"Action\": [\n" +
            "        \"s3:GetBucketLocation\",\n" +
            "        \"s3:ListBucket\",\n" +
            "        \"s3:ListBucketMultipartUploads\"\n" +
            "      ],\n" +
            "      \"Resource\": [\n" +
            "        \"arn:aws:s3:::%s\"\n" +
            "      ]\n" +
            "    },\n" +
            "    {\n" +
            "      \"Effect\": \"Allow\",\n" +
            "      \"Principal\": {\n" +
            "        \"AWS\": [\n" +
            "          \"*\"\n" +
            "        ]\n" +
            "      },\n" +
            "      \"Action\": [\n" +
            "        \"s3:AbortMultipartUpload\",\n" +
            "        \"s3:DeleteObject\",\n" +
            "        \"s3:GetObject\",\n" +
            "        \"s3:ListMultipartUploadParts\",\n" +
            "        \"s3:PutObject\"\n" +
            "      ],\n" +
            "      \"Resource\": [\n" +
            "        \"arn:aws:s3:::%s/*\"\n" +
            "      ]\n" +
            "    }\n" +
            "  ]\n" +
            "}";
    public static String setPublic(String bucketName) {
        return String.format(PUBLIC_POLICY, bucketName, bucketName);
    }
}
